package com.activiti.ActivitiUtils.runtime;

import com.activiti.ActivitiUtils.bean.Page;
import com.activiti.ActivitiUtils.bean.WrappedProcessDefinitionBean;
import com.activiti.ActivitiUtils.bean.WrappedProcessInstanceBean;
import com.activiti.ActivitiUtils.builder.payload.process.definition.ProcessDefinitionLimitOnePayload;
import com.activiti.ActivitiUtils.builder.payload.process.definition.ProcessDefinitionQueryPayload;
import com.activiti.ActivitiUtils.builder.payload.process.instance.ProcessInstanceLimitOnePayload;
import com.activiti.ActivitiUtils.builder.payload.process.instance.ProcessInstanceQueryPayload;
import com.activiti.ActivitiUtils.builder.payload.process.instance.ProcessInstanceStartPayload;

import java.util.List;
import java.util.Map;

/**
 * create by chongyahhh
 * 2020/4/4
 */
public interface WrappedProcessRuntime {
    /**
     * 获取流程定义信息
     * @param processDefinitionsPayload ：只要processDefinitionId和key，填哪个就用哪个查
     * @return
     */
    WrappedProcessDefinitionBean getProcessDefinition(ProcessDefinitionLimitOnePayload processDefinitionsPayload);

    /**
     * 获取流程定义列表
     * @param processDefinitionsPayload ： 只要两个set，用哪个放哪个
     * @return
     */
    List<WrappedProcessDefinitionBean> getProcessDefinitionList(ProcessDefinitionQueryPayload processDefinitionsPayload);

    /**
     * 分页获取
     * @param processDefinitionsPayload ： 只要两个set，用哪个放哪个
     * @param pageNum
     * @param pageSize
     * @return
     */
    Page<List<WrappedProcessDefinitionBean>> getProcessDefinitionPages(ProcessDefinitionQueryPayload processDefinitionsPayload, Integer pageNum, Integer pageSize);

    /**
     * 看一个流程定义是否被挂起
     * @param processDefinitionsPayload : 只要processDefinitionId和key，填哪个就用哪个查
     * @return true -> 被挂起；false -> 没被挂起；null -> 实例不存在
     */
    Boolean isProcessDefinitionSuspend(ProcessDefinitionLimitOnePayload processDefinitionsPayload);

    /**
     * 挂起或激活一个流程定义
     * @return
     */
    WrappedProcessDefinitionBean suspendOrActiveProcessDefinition(ProcessDefinitionLimitOnePayload processDefinitionsPayload);

    /**
     * 获取流程实例
     * @param processInstancesPayload : 放businessKey或id
     * @return
     */
    WrappedProcessInstanceBean getProcessInstance(ProcessInstanceLimitOnePayload processInstancesPayload);

    /**
     * 获取流程实例列表
     * @param processInstancesPayload : 放俩set
     * @return
     */
    List<WrappedProcessInstanceBean> getProcessInstanceList(ProcessInstanceQueryPayload processInstancesPayload);

    /**
     * 分页获取流程实例
     * @param processInstancesPayload : 放俩set和俩boolean
     * @param pageNum
     * @param pageSize
     * @return
     */
    Page<List<WrappedProcessInstanceBean>> getProcessInstancePages(ProcessInstanceQueryPayload processInstancesPayload, Integer pageNum, Integer pageSize);

    /**
     * 开启流程
     * @param processInstancesPayload : processDefinitionKey和processDefinitionId必须放一个，map和businessKey需要放就放
     * @return
     */
    WrappedProcessInstanceBean start(ProcessInstanceStartPayload processInstancesPayload);

    /**
     * 看一个流程实例是否被挂起
     * @param processInstancesPayload : 只要businessKey和id，填哪个就用哪个查
     * @return true -> 被挂起；false -> 没被挂起; null -> 实例不存在
     */
    Boolean isProcessInstanceSuspend(ProcessInstanceLimitOnePayload processInstancesPayload);

    /**
     * 挂起或激活一个流程
     * 只要businessKey或id
     * @return
     */
    WrappedProcessInstanceBean suspendOrActiveProcessInstance(ProcessInstanceLimitOnePayload processInstancesPayload);

    /**
     * 更新businessKey
     * @return
     */
    WrappedProcessInstanceBean updateBusinessKey(String processInstanceId, String businessKey);

    /**
     * 添加流程变量
     * 只要id和variables
     */
    void setVariables(String executionId, Map<String, Object> variables);

    /**
     * 获取流程变量
     * @param executionId ：只要executionId
     * @return
     */
    Map<String,Object> getVariables(String executionId);

    /**
     * 移除变量
     * @param executionId
     * @param variableNames
     */
    void removeVariables(String executionId, List<String> variableNames);

}
